/**
 * 2016，thor.com，all rights reserved。
 * 
 * Project：		palmmall-core
 * Filename：	SComplaintConverter.java
 * Created：		2016年8月21日
 * Creator：		wolv
 */
package com.thor.palmmall.rest.repair.converter;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.UCN;
import com.thor.palmmall.rest.common.SSubjectWithDirectionConverter;
import com.thor.palmmall.rest.repair.AFeeRecord;
import com.thor.palmmall.spi.maintain.SFeeRecord;

/**
 * @author wolv
 *
 */
public class SFeeRecordConverter implements Converter<AFeeRecord, SFeeRecord> {

	public static SFeeRecordConverter getInstance() {
		if (instance == null)
			instance = new SFeeRecordConverter();
		return instance;
	}

	private static SFeeRecordConverter instance;

	private SFeeRecordConverter() {
	}

	@Override
	public SFeeRecord convert(AFeeRecord source) {
		if (source == null)
			return null;

		SFeeRecord target = new SFeeRecord();
		target.setMaterial(UCN.newInstance(source.getMaterial()));
		target.setPrice(source.getPrice());
		target.setQty(source.getQty());
		target.setSpecification(source.getSpecification());
		target.setSubject(SSubjectWithDirectionConverter.getInstance().convert(source.getSubject()));
		target.setTotal(source.getTotal());
		target.setWarehouse(UCN.newInstance(source.getWarehouse()));

		return target;
	}
}
